<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <title>{{ test_title }} 自动化测试报告</title>
</head>

<body
    style="margin:0;padding:40px;background:#f4f6f8;font-family:-apple-system,Segoe UI,Roboto,Helvetica Neue,sans-serif;color:#333;">
    <div
        style="max-width:660px;margin:0 auto;background:#eeeeee;border-radius:12px;box-shadow:0 6px 18px rgba(0,0,0,0.06);overflow:hidden;">

        <!-- Header -->
        <div style="background:#2b85d3;color:#fff;padding:28px 32px;font-size:20px;font-weight:600;">
            📋 {{ test_title }} 自动化测试报告
        </div>

        <!-- Body -->
        <div style="padding:30px 32px;font-size:15px;line-height:1.9;">
            <table style="width:100%;border-collapse:collapse;">
                <tbody>
                    <tr>
                        <td>👤 <strong>测试人员：</strong> {{ tester_name }}</td>
                    </tr>
                    <tr>
                        <td>📅 <strong>执行日期：</strong> {{ started_time[:10] }} ⏰ {{ started_time[11:] }}</td>
                    </tr>
                    <tr>
                        <td>📁 <strong>总用例数：</strong> {{ passed + failed + error + skipped }}</td>
                    </tr>
                </tbody>
            </table>

            <!-- 统计 -->
            <div style="margin-top:24px;">
                <div><strong>📊 执行结果：</strong></div>
                <table style="width:100%;margin-top:8px;font-size:15px;">
                    <tr>
                        <td>✅ 通过用例：<strong>{{ passed }}</strong></td>
                        <td>🔧 失败用例：<strong>{{ failed }}</strong></td>
                    </tr>
                    <tr>
                        <td>❌ 错误用例：<strong>{{ error }}</strong></td>
                        <td>⚠️ 跳过用例：<strong>{{ skipped }}</strong></td>
                    </tr>
                </table>
            </div>

            <!-- 通过率 -->
            {% set total = passed + failed + error + skipped %}
            {% set rate = (passed * 100 // total) if total > 0 else 0 %}
            <div style="margin-top:24px;">
                <div><strong>📈 用例通过率：</strong> <span
                        style="display:inline-block;background:#52c41a;color:white;padding:2px 8px;border-radius:8px;font-size:13px;">{{
                        rate }}%</span></div>
                <div style="width:100%;background:#eee;border-radius:8px;overflow:hidden;height:12px;margin-top:8px;">
                    <div style="background:#52c41a;height:100%;"
                         {% if rate is defined %}style="width:{{ rate }}%;background:#52c41a;height:100%;"{% else %}style="width:0;background:#52c41a;height:100%;"{% endif %}></div>
                </div>
            </div>

            <!-- 查看报告 -->
            {% if report_url %}
            <div style="margin-top:32px;text-align:center;">
                <a href="{{ report_url }}"
                    style="background:#2b85d3;color:#fff;padding:10px 24px;border-radius:6px;text-decoration:none;font-weight:500;display:inline-block;">
                    🔍 查看Jenkins Allure完整报告
                </a>
            </div>
            {% endif %}

            <!-- 用例详情展示（示例结构，可动态生成） -->
            {% if case_details %}
            <div style="margin-top:36px;">
                <strong>🧾 用例详情：</strong>
                <ul style="padding-left:20px;margin-top:12px;font-size:14px;line-height:1.6;">
                    {% for case in case_details %}
                    <li>{{ case.module }} / {{ case.name }} —
                        {% if case.status == 'pass' %}
                        ✅ 通过
                        {% elif case.status == 'fail' %}
                        ❌ 失败
                        {% elif case.status == 'error' %}
                        🚫 错误
                        {% elif case.status == 'skip' %}
                        ⚠️ 跳过
                        {% endif %}
                    </li>
                    {% endfor %}
                </ul>
            </div>
            {% endif %}
        </div>

        <!-- Footer -->
        <div style="background:#dfdfdf;text-align:center;font-size:12px;color:#777;padding:16px 20px;">
            此邮件由 AutoAPI 于 {{ generated_time }} 自动生成 · 请勿直接回复
        </div>
    </div>
</body>

</html>